url_encode

This function encodes a string to be URL compatible.

string url_encode(string url)

Parameters:
url
The URL string to encode.

Return value:
The encoded string on success, or the passed string on failure.

Remarks:
The url_encode function converts special characters that cannot be used on their own to specially adapted combinations that represent that character that are legal. Therefore it is important to use this function when using any of the HTTP functions for them to work properly.

Example:
// Encode a URL.

void main()
{
alert("encoded url",url_encode("http://www.mysite.com/files/my program (v1.0).exe")); // Reads http%3a%2f%2fwww.mysite.com%2ffiles%2fmy+program+%28v1.0%29.exe
}